home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-PPC / HARDIRQ.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  1KB  |  64 lines

  1. #ifndef __ASM_HARDIRQ_H
  2. #define __ASM_HARDIRQ_H
  3.  
  4. extern unsigned int local_irq_count[NR_CPUS];
  5.  
  6. /*
  7.  * Are we in an interrupt context? Either doing bottom half
  8.  * or hardware interrupt processing?
  9.  */
  10. #define in_interrupt() ({ int __cpu = smp_processor_id(); \
  11.     (local_irq_count[__cpu] + local_bh_count[__cpu] != 0); })
  12.  
  13. #ifndef __SMP__
  14.  
  15. #define hardirq_trylock(cpu)    (local_irq_count[cpu] == 0)
  16. #define hardirq_endlock(cpu)    do { } while (0)
  17.  
  18. #define hardirq_enter(cpu)    (local_irq_count[cpu]++)
  19. #define hardirq_exit(cpu)    (local_irq_count[cpu]--)
  20.  
  21. #define synchronize_irq()    do { } while (0)
  22.  
  23. #else /* __SMP__ */
  24.  
  25. #include <asm/atomic.h>
  26.  
  27. extern unsigned char global_irq_holder;
  28. extern unsigned volatile int global_irq_lock;
  29. extern atomic_t global_irq_count;
  30.  
  31. static inline void release_irqlock(int cpu)
  32. {
  33.     /* if we didn't own the irq lock, just ignore.. */
  34.     if (global_irq_holder == (unsigned char) cpu) {
  35.         global_irq_holder = NO_PROC_ID;
  36.         clear_bit(0,&global_irq_lock);
  37.     }
  38. }
  39.  
  40. static inline void hardirq_enter(int cpu)
  41. {
  42.     ++local_irq_count[cpu];
  43.     atomic_inc(&global_irq_count);
  44. }
  45.  
  46. static inline void hardirq_exit(int cpu)
  47. {
  48.     atomic_dec(&global_irq_count);
  49.     --local_irq_count[cpu];
  50. }
  51.  
  52. static inline int hardirq_trylock(int cpu)
  53. {
  54.     return !atomic_read(&global_irq_count) && !test_bit(0,&global_irq_lock);
  55. }
  56.  
  57. #define hardirq_endlock(cpu)    do { } while (0)
  58.  
  59. extern void synchronize_irq(void);
  60.  
  61. #endif /* __SMP__ */
  62.  
  63. #endif /* __ASM_HARDIRQ_H */
  64.